package thread;

public class ThreadDemo15 {
    public static void main(String[] args) {
        Object A = new Object();
        Object B = new Object();
        Thread t = new Thread(() ->{
           synchronized (A){
               try {
                   Thread.sleep(1000);
               } catch (InterruptedException e) {
                   throw new RuntimeException(e);
               }
               synchronized (B){
                   System.out.println("t获得了俩把锁");
               }
           }
        });
        Thread tt = new Thread(() ->{
           synchronized (B){
               try {
                   Thread.sleep(1000);
               } catch (InterruptedException e) {
                   throw new RuntimeException(e);
               }
               synchronized (A){
                   System.out.println("tt获得了俩把锁");
               }
           }
        });
        t.start();
        tt.start();
    }
}
